"""
IoT智能家居控制系统 URL配置
"""
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic import RedirectView
from . import views

# 设置管理后台标题
admin.site.site_header = 'IoT智能家居控制系统'
admin.site.site_title = 'IoT智能家居'
admin.site.index_title = '系统管理'

urlpatterns = [
    # 管理后台
    path('admin/', admin.site.urls),
    
    # 主页重定向到设备管理
    path('', RedirectView.as_view(url='/devices/', permanent=False), name='home'),
    
    # 各应用URL
    path('devices/', include('apps.devices.urls')),
    path('scenes/', include('apps.scenes.urls')),
    path('users/', include('apps.users.urls')),
    path('nlp/', include('apps.nlp.urls')),
    
    # API接口
    path('api/v1/devices/', include('apps.devices.api_urls')),
    path('api/v1/scenes/', include('apps.scenes.api_urls')),
    path('api/v1/users/', include('apps.users.api_urls')),
    path('api/v1/nlp/', include('apps.nlp.api_urls')),
    
    # 认证相关
    path('auth/', include('django.contrib.auth.urls')),
    path('auth/profile/', views.profile_view, name='profile'),
]

# 开发环境下的静态文件和媒体文件服务
if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
